<template>
  <div v-if="!openRoute">
    <van-tabbar v-model="value" @change="onChange">
      <van-tabbar-item name="/index" icon="home-o">首页</van-tabbar-item>
      <van-tabbar-item name="/shop" icon="search">购物车</van-tabbar-item>
      <van-tabbar-item name="/talk" icon="friends-o">评论</van-tabbar-item>
      <van-tabbar-item name="/people" icon="setting-o">我的</van-tabbar-item>
    </van-tabbar>
  </div>
  <div v-else>
    <van-tabbar route>
      <van-tabbar-item to="/index" icon="home-o">首页</van-tabbar-item>
      <van-tabbar-item to="/shop" icon="search">购物车</van-tabbar-item>
      <van-tabbar-item to="/talk" icon="friends-o">评论</van-tabbar-item>
      <van-tabbar-item to="/people" icon="setting-o">我的</van-tabbar-item>
    </van-tabbar>
  </div>
</template>

<script>
export default {
  data() {
    return {
      value: 0,
    };
  },
  props: {
    active: {
      type: String,
      default: "",
    },
    openRoute: {
      type: Boolean,
      default: false,
    },
  },
  model: {
    prop: "active",
    event: "input",
  },
  created() {
    this.value = this.active;
  },
};
</script>

<style></style>
